<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
[#include "/WEB-INF/pages/common/taglibs.ftl"]
[#if piece=true]
	[#include "/WEB-INF/pages/manage/_media.ftl"]
[#else]

	<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Insert title here</title>
		<meta name="menu" content="AdminMenu"/>
		<meta name="heading" content="heading"/>
		<meta name="media" content="current"/>
		<meta name="mediaurl" content="[@c.url value='/manage/Media_list.action'][@c.param name='pid' value='${pid}'/][/@c.url]"/>
		<meta name="formurl" content="[@c.url value='/manage/Article_create.action'][@c.param name='pid' value='${pid}'/][/@c.url]"/>
		<meta name="extendsurl" content="[@c.url value='/manage/Extension_list.action'][@c.param name='pid' value='${pid}'/][/@c.url]"/>
		
		<link rel="stylesheet" href="[@c.url value='/js/plugins/jquery-jcrop/jquery.Jcrop.min.css'/]">
		<!-- The localization script
		<script src="[@c.url value='/js/plugins/jquery-fileupload/js/locale.js'/]"></script> -->
		
		<!--图片剪切-->
		<script src="[@c.url value='/js/plugins/jquery-jcrop/jquery.Jcrop.min.js'/]"></script>
		<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.alerts.js'/]"></script>
		<script type="text/javascript" src="[@c.url value='/js/custom/media.js'/]"></script>
		<script type="text/javascript" src="[@c.url value='/js/plugins/jquery.colorbox-min.js'/]"></script>
		
		<style type="text/css">
	
		</style>
		<script type="text/javascript">
			var base = (function(){
				// 事件绑定
				function _addEventListeners() {
					// 删除事件绑定
					$('.imagelist .delete').click(function(){
						var content = "是否删除图片";
						var title = "删除操作";
						var uuid = $(this).attr('id');
						var parent = $(this).parents('li');
						jConfirm(content, title, function(r) {
							if (r) {
								[@c.url	var="deleteUrl" value='/manage/Media_deletephoto.action' scope="page" /]
								$.get('${deleteUrl}', {'id':'${id}','uuid':uuid, 'ajax':true}, function(result) {
									parent.hide('explode',500);
								})
							}
						});
					});
					
					//image view
					$('.view').colorbox();
				}
				// KCFinder的事件绑定
				function _kcfinderEventListener(id) {
					var $div = $('#'+id);
					//由joiner.js的回调函数自动调用
				    window.KCFinder = {
				        callBack: function(url, uuid) {
							//将图片文件插入到文章的文档中
							var params = {'ajax':true};
							params.id = '${id}';
							params.path = url;
							params.uuid = uuid;
				            $.post("[@c.url value='/manage/Media_addphoto.action' /]", params, function(e){
				           		$.get("[@c.url value='/manage/Media_list.action' /]", {'id': '${id}', 'ajax':'true', 'piece':'true'}, function(result){
				           			$('#mediaImg').html(result);
				           			// 
				           			base.init();
				           		});
				            })
				        }
				    };
					$div.append('<iframe name="kcfinder2_iframe" src="[@c.url value="/kcfinder/browse.kc?act=show&type=images&dir=public"/]" ' +
		        	'frameborder="0" width="100%" height="100%" marginwidth="0" marginheight="0" scrolling="no" />');
		    		$div.css({display:'block'}).show();
				}
				return {
	                config: {
	                	url : null,
	                    theme: null
	                },
	                init: function () {
	                	_addEventListeners();
	                },
	                kc: function(id) {
	                	_kcfinderEventListener(id);
	                }
				}
			}());
			
			$(function(){
				var link = "[@c.url value='/manage/Member_list.action?currentPage=${currentPage}' /]";
				base.config.theme = getTheme();
				base.config.url = link;
	            //Initializing the form
				base.init();
				base.kc('tableoptions');
			})
		</script>
	</head>
	<body id="body">
		<!--设置提交行为-->
		[#assign act="update" /]
		[#include "/WEB-INF/pages/manage/_media.ftl"]
	</body>
	</html>

[/#if]